package com.consumer.service;

import com.api.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * UserService服务的消费者组件
 * 使用@DubboReference注解引用远程的UserService服务
 */
@Component
public class UserServiceConsumer {

    /**
     * 引用远程的UserService服务
     */
    @DubboReference
    private UserService userService;

    /**
     * 调用远程服务获取用户名
     *
     * @param userId 用户ID
     * @return 用户名
     */
    public String getUserName(Long userId) {
        return userService.getUserNameById(userId);
    }
}